<!-- 耗材管理-基础资料-耗材分类 -->
<template>
  <div class="JNPF-common-layout">
    <div class="JNPF-common-layout-center">
      <el-row class="JNPF-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="6">
            <el-form-item label="客户名称">
              <el-input v-model="listQuery.fsiteNo" placeholder="请输入名称" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="楼栋">
              <el-select v-model="listQuery.fpointNo" placeholder="请选择">
                <el-option
                  v-for="item in selectlist1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="楼栋类型">
              <el-select v-model="listQuery.fpointFlag" placeholder="请选择">
                <el-option
                  v-for="item in selectlist2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="">
              <el-button type="primary" icon="el-icon-search" @click="getlist">查询</el-button>
              <el-button type="success" icon="el-icon-plus" @click="insert(undefined)">新增</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="JNPF-common-layout-main JNPF-flex-main">
        <JNPF-table :data="list" border v-loading="loading">
          <el-table-column prop="FCATNO" label="客户名称"></el-table-column>
          <el-table-column prop="fpointNo" label="楼栋编号"></el-table-column>
          <el-table-column prop="fpointName" label="楼栋名称"> </el-table-column>
          <el-table-column prop="FMEMO" label="楼栋类型"> </el-table-column>
          <el-table-column prop="fpointState" label="状态"> </el-table-column>
          <el-table-column fixed="left" label="操作" width="150">
            <template slot-scope="scope">
              <el-button @click.native.prevent="insert(scope.row)" icon="el-icon-edit" type="text" size="small">
                编辑
              </el-button>
              <el-popconfirm title="确定删除当前数据吗？" @confirm="HandelDel(scope.row.fpointNo)">
                <el-button slot="reference" icon="el-icon-delete" style="color: red;margin-left: 10px;"
                  type="text">删除</el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </JNPF-table>
        <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" />
        <Form ref="Form" :parelist="list" />
      </div>
    </div>
  </div>
</template>

<script>
  import Form from "./Form.vue"
  import {list,getroom,deleteRoom} from "@/api/data/room"
  export default {
    name: 'shop',
    components: { Form },
    data() {
      return {
        total: 0,
        list: [],
        selectlist1:[],
        selectlist2:[
          {
            "label": "室内",
            "value": "1"
          },
          {
            "label": "室外",
            "value": "2"
          }
        ],
        loading: false,
        listQuery: {
          page: 1,
          limit: 20,
          sort: "desc",
          sidx: "",
          fsiteNo:"300017",
          fpointNo:undefined,
          roomtype:undefined
        },
      };
    },
    computed: {},
    created() {
      this.geTRoom();
      this.getlist();
    },
    methods: {
      //
      getlist(){
        list(this.listQuery)
        .then(res=>{
          this.list=res.data.list
        })
      },
      //
      geTRoom(){
        getroom().then(res=>{
          this.selectlist1=res.data.list;
        })

        
      },
      HandelDel(id){
        deleteRoom(id)
        .then(res=>{
          this.$message({
            message: '删除成功',
            type: 'success'
          });
          this.getlist();
        })
      },
      //
      insert(row) {
        this.$refs.Form.init(row);
      },
    },
  };
</script>